package com.frxuexi.mynews

import com.frxuexi.mynews.entity.BaseEntity
import com.frxuexi.mynews.entity.CommentEntity
import com.frxuexi.mynews.entity.NewsDataEntity
import com.frxuexi.mynews.entity.NewsDetailEntity
import com.frxuexi.mynews.entity.NewsTypeEntity
import com.frxuexi.mynews.entity.VideoDataEntity
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface ApiService {

    //新闻类型
    @GET("/api/nt/all")
    fun getNewsType():Flow<BaseEntity<List<NewsTypeEntity>>>

    //新闻列表
    @GET("/api/news/page?size=10")
    fun getNews(@Query("page") page:Int,@Query("type")type:Int):Flow<BaseEntity<NewsDataEntity>>

    //登录
    @POST("/api/user/loginname")
    fun login(@Body body: RequestBody):Flow<BaseEntity<String>>

    //新闻详情
    @GET("/api/news/detail")
    fun getNewsDetail(@Query("id")id:Int):Flow<BaseEntity<NewsDetailEntity>>

    //收藏
    @GET("/api/newsCollect/collect")
    fun newsCollect(@Query("nid")nid:Int):Flow<BaseEntity<String>>

    //查询我的收藏，这条数据是否收藏过，根据结果显示收藏图标
    @GET("/api/newsCollect/my")
    fun myCollect():Flow<BaseEntity<List<NewsDetailEntity>>>

    //发布评论
    @POST("/api/newsComment/save")
    fun newsComment(@Body body: RequestBody):Flow<BaseEntity<String>>

    //根基新闻id获取评论
    @GET("/api/newsComment/comments")
    fun getCommentsById(@Query("nid")nid: Int):Flow<BaseEntity<List<CommentEntity>>>

    //获取视频列表
    @GET("/api/video/page?order=1&size=10")
    fun getVideos(@Query("page")page:Int):Flow<BaseEntity<VideoDataEntity>>
}